﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using System.Web.Routing;
using Xpus.YouYTube.WebSite.Models;

namespace Xpus.YouYTube.WebSite
{
	public class GlobalApplication : System.Web.HttpApplication
	{
		public static void RegisterRoutes(RouteCollection routes)
		{
			routes.Add(new Route("video/list/{by}/{pageIndex}/{pageSize}", new MvcRouteHandler())
			{
				Defaults = new RouteValueDictionary(new { controller = "Video", action = "List", by = TVideoListType.ByTime, pageIndex = 1, pageSize = 50 }),
			});

			routes.Add(new Route("{controller}/{action}/{id}", new MvcRouteHandler())
			{
				Defaults = new RouteValueDictionary(new { action = "Index", id = "" }),
			});

			routes.Add(new Route("Default.aspx", new MvcRouteHandler())
			{
				Defaults = new RouteValueDictionary(new { controller = "Home", action = "Index", id = "" }),
			});
		}

		protected void Application_Start(object sender, EventArgs e)
		{
			RegisterRoutes(RouteTable.Routes);
		}
	}
}